package org.KeyCrafter.util;

import java.io.IOException;
import java.util.Properties;

import static org.KeyCrafter.server.ServerConstants.CONF_FILE_PATH;

public class ConfigUtils {
    private static final Properties confProps;

    // 读取默认配置文件
    static {
        confProps = new Properties();
        try {
            confProps.load(ConfigUtils.class.getResourceAsStream(CONF_FILE_PATH));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private ConfigUtils() {
    }
    public static int getIntProperty(String key) {
        return Integer.parseInt(confProps.getProperty(key));
    }
    public static boolean getBoolProperty(String key) {
        return Boolean.parseBoolean(confProps.getProperty(key));
    }
    public static String getProperty(String key) {
        return confProps.getProperty(key);
    }
}
